/* GUI CONVERTED from wopkall.p (converter v1.75) Sat Aug 12 16:37:15 2000 */
/* wopkall.p - WORK ORDER PICK LIST HARD ALLOCATIONS                    */
/* Copyright 1986-2000 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*K1Q4*/ /*V8:WebEnabled=No                                             */
/* REVISION: 6.0      LAST MODIFIED: 05/03/90   BY: MLB **D024**/
/* REVISION: 6.0      LAST MODIFIED: 05/30/90   BY: emb */
/* REVISION: 6.0      LAST MODIFIED: 10/07/91   BY: alb *D887*(rev only) */
/* REVISION: 7.3      LAST MODIFIED: 02/08/93   BY: emb *G656*/
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan    */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KC* myb           */
/*  CONVERTED from wkpkall.p 2009-9-25 14:21:17 BY: zy                   */

     define shared variable hiud_recno as recid.
     define shared variable qty_to_all like wod_qty_all.

     define variable all_this_loc like wod_qty_all.
     define buffer lddet for ld_det.
     define variable this_lot like ld_lot.

     define variable flowOrder as logical.
     define variable batchrun  as logical initial YES.

     find first icc_ctrl no-lock.
     find hiud_det where recid(hiud_det) = hiud_recno.
     find first hiu_mstr no-lock where hiu_nbr = hiu_nbr no-error.

     this_lot = ?.

     if qty_to_all > 0 then do:

        find pt_mstr where pt_part = hiud_part no-lock no-error.
        if pt_sngl_lot then do:
           find first lad_det no-lock where lad_dataset = "hiud_det"
/*G656*        and lad_nbr = wod_nbr and lad_line = wod_lot */
/*G656*/       and lad_nbr = hiud_nbr and lad_line = hiud_nbr
           and lad_part = hiud_part
           and (lad_qty_all > 0 or lad_qty_pick > 0) no-error.
           if available lad_det then this_lot = lad_lot.
        end.

        if icc_ascend then do:
           if icc_pk_ord <= 2 then do:
          {hkhiupkall.i
           &sort1 = "(if icc_pk_ord = 1 then ld_loc else ld_lot)" }
           end.
           else do:
          {hkhiupkall.i
          &sort1 = "(if icc_pk_ord = 3 then ld_date else ld_expire)" }
           end.
        end.
        else do:
           if icc_pk_ord <= 2 then do:
          {hkhiupkall.i
          &sort1 = "(if icc_pk_ord = 1 then ld_loc else ld_lot)"
          &sort2 = "descending"}
           end.
           else do:
          {hkhiupkall.i
          &sort1 = "(if icc_pk_ord = 3 then ld_date else ld_expire)"
          &sort2 = "descending"}
           end.
        end.
     end.
